package com.lemon.exam.entity.po;

import com.lemon.exam.common.constant.ApiConst;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

/**
 * 日志实体类对象
 *
 * @author Lemon
 * @since 2025/4/25 11:52
 */
@Getter
@Setter
@Schema(name = "日志")
@Document(indexName = ApiConst.ES_LOGGING_INDEX)
public class LoggingPO implements Serializable {
    @Id
    @Schema(description = "ID")
    private Long id;

    @Schema(description = "用户ID")
    @Field(type = FieldType.Long)
    private Long userId;

    @Schema(description = "用户名")
    @Field(type = FieldType.Text)
    private String username;

    @Schema(description = "IP地址")
    @Field(type = FieldType.Text)
    private String ip;

    @Schema(description = "请求的URI")
    @Field(type = FieldType.Text)
    private String uri;

    @Schema(description = "说明")
    @Field(type = FieldType.Text)
    private String content;

    @Schema(description = "请求方式")
    @Field(type = FieldType.Text)
    private String method;

    @Schema(description = "请求参数")
    @Field(type = FieldType.Text)
    private String param;

    @Schema(description = "请求体参数")
    @Field(type = FieldType.Text)
    private String body;

    @Schema(description = "持续时间")
    @Field(type = FieldType.Long)
    private Long duration;

    @Schema(description = "响应状态码")
    @Field(type = FieldType.Integer)
    private Integer code;

    @Schema(description = "创建时间")
    //@Field(type = FieldType.Date, format = DateFormat.epoch_millis)
    @Field(type = FieldType.Long)
    private Long createTime;
}
